//
//  CJCompanyMemberCell.m
//  Boss
//
//  Created by admin on 2018/9/14.
//  Copyright © 2018年 admin. All rights reserved.
//

#import "CJCompanyMemberCell.h"
#import "CJCJCompanyMemberCollectionCell.h"
#import "CJFirmUserListModel.h"
@interface CJCompanyMemberCell()<UICollectionViewDelegate,UICollectionViewDataSource>

@property (strong, nonatomic) IBOutlet UICollectionView *collectionView;



@end
@implementation CJCompanyMemberCell

-(void)setDataArray:(NSArray *)dataArray
{
    _dataArray = dataArray;
    [self.collectionView reloadData];
}


- (void)awakeFromNib {
    [super awakeFromNib];
    [self setupUI];
    // Initialization code
}

-(void)setupUI
{
    self.collectionView.delegate = self;
    self.collectionView.dataSource = self;
    
    UICollectionViewFlowLayout *layout=[[UICollectionViewFlowLayout alloc]init];
    layout.itemSize=CGSizeMake(120, 140);
    //横向最小距离
    layout.minimumInteritemSpacing=5.0f;
    layout.minimumLineSpacing=5.0f;
    //cell距离上  左  下 右 的距离
    layout.sectionInset=UIEdgeInsetsMake(10, 10, 10, 10);
    [layout setScrollDirection:UICollectionViewScrollDirectionHorizontal];
    [self.collectionView setCollectionViewLayout:layout];
    //  [layout setHeaderReferenceSize:CGSizeMake(kScreenWidth, 44)];
    [self.collectionView registerNib:[UINib nibWithNibName:@"CJCJCompanyMemberCollectionCell" bundle:nil] forCellWithReuseIdentifier:@"CJCJCompanyMemberCollectionCell"];
}

-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
{

    return 1;

}
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return self.dataArray.count;
}
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    CJCJCompanyMemberCollectionCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"CJCJCompanyMemberCollectionCell" forIndexPath:indexPath];
    if (!cell) {
        cell = [[NSBundle mainBundle]loadNibNamed:@"CJCJCompanyMemberCollectionCell" owner:nil options:nil].firstObject;
    }
    CJFirmUserListModel *model = self.dataArray[indexPath.row];
    [cell setModel:model];
    
//    cell.backgroundColor =[UIColor redColor];
    
    
    return cell;
}





- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
